package com.link2room.rodimus;

import com.link2room.common.mns.Worker;
import com.link2room.common.mns.listener.MnsListener;
import com.link2room.common.util.LogUtil;
import com.link2room.rodimus.constant.RodimusMnsConstant;
import org.slf4j.Logger;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 加载mns消息服务轮询服务
 * Created by LN on 2016/8/25.
 */
@Component  //使用时，打开注释
public class RodimusMNSPollingPMSMemberRunner implements CommandLineRunner {

    @Resource
    private Worker pmsMemberRunner;
    @Resource
    private Worker pmsRodimusReservationRunner;
    @Resource
    private Worker salemanAwardMemberRunner;
    @Resource
    private Worker mallOrderCancelRunner;
    @Resource
    private Worker salemanAwardReservationRunner;
    @Resource
    private Worker groupbuyingTeamAutoCancelWorker;
    @Resource
    private Worker groupbuyingTeamAutoRefundWorker;
    @Resource
    private Worker pmsCheckOutDoRunner;
    @Resource
    private Worker invoiceDetailRunner;
    @Resource
    private Worker pointRunner;
    @Resource
    private Worker couponPresentResetWorker;
    @Resource
    private Worker signInDistributeAwardWorker;
    @Resource
    private MnsListener defaultMnsListener;

    private static Logger logger = LogUtil.logger;
    @Override
    public void run(String... strings) throws Exception {
        logger.info("start mns polling task:"+ RodimusMnsConstant.QUEUE_PMS_MEMBER);
        defaultMnsListener.startPolling(RodimusMnsConstant.QUEUE_PMS_MEMBER,pmsMemberRunner);
        //订单RODIMUS队列
        logger.info("start mns polling task:"+RodimusMnsConstant.QUEUE_ORDER_RODIMUS);
        defaultMnsListener.startPolling(RodimusMnsConstant.QUEUE_ORDER_RODIMUS,pmsRodimusReservationRunner);
        //销售员粉丝奖励
        logger.info("start mns polling task:"+RodimusMnsConstant.QUEUE_SALEMAN_INCOME_TRANSFER);
        defaultMnsListener.startPolling(RodimusMnsConstant.QUEUE_SALEMAN_INCOME_TRANSFER,salemanAwardMemberRunner,5);
        //销售员订单奖励
        logger.info("start mns polling task:"+RodimusMnsConstant.QUEUE_SALEMAN_INCOME_TRANSFER_RESERVATION);
        defaultMnsListener.startPolling(RodimusMnsConstant.QUEUE_SALEMAN_INCOME_TRANSFER_RESERVATION,salemanAwardReservationRunner,5);
        //荟评网调查问卷
        logger.info("start mns polling task:"+RodimusMnsConstant.QUEUE_BRANDWISDOM_GSS);
        defaultMnsListener.startPolling(RodimusMnsConstant.QUEUE_BRANDWISDOM_GSS, pmsCheckOutDoRunner);
        //订单积分兑换
        logger.info("start mns polling task:"+RodimusMnsConstant.QUEUE_ORDER_POINT_RODIMUS);
        defaultMnsListener.startPolling(RodimusMnsConstant.QUEUE_ORDER_POINT_RODIMUS,pointRunner);

        //券分享重置
        logger.info("start mns polling task:"+RodimusMnsConstant.QUEUE_RESET_PRESENT_COUPON);
        defaultMnsListener.startPolling(RodimusMnsConstant.QUEUE_RESET_PRESENT_COUPON,couponPresentResetWorker);

        //发票请求
        logger.info("start mns polling task:"+RodimusMnsConstant.QUEUE_ORDER_INVOICE);
        defaultMnsListener.startPolling(RodimusMnsConstant.QUEUE_ORDER_INVOICE,invoiceDetailRunner);

        //商城订单取消
        logger.info("start mns polling task:"+RodimusMnsConstant.QUEUE_MALL_ORDER_CANCEL);
        defaultMnsListener.startPolling(RodimusMnsConstant.QUEUE_MALL_ORDER_CANCEL,mallOrderCancelRunner);

        //团购订单取消
        logger.info("start mns polling task:"+RodimusMnsConstant.QUEUE_GROUPBUYING_AUTO_CANCEL);
        defaultMnsListener.startPolling(RodimusMnsConstant.QUEUE_GROUPBUYING_AUTO_CANCEL,groupbuyingTeamAutoCancelWorker);

        //团购自动退款
        logger.info("start mns polling task:"+RodimusMnsConstant.QUEUE_GROUPBUYING_AUTO_REFUND);
        defaultMnsListener.startPolling(RodimusMnsConstant.QUEUE_GROUPBUYING_AUTO_REFUND,groupbuyingTeamAutoRefundWorker);
        //签到分发
        logger.info("start mns polling task:"+RodimusMnsConstant.QUEUE_SIGN_IN_DISTRIBUTE_AWARD);
        defaultMnsListener.startPolling(RodimusMnsConstant.QUEUE_SIGN_IN_DISTRIBUTE_AWARD,signInDistributeAwardWorker);






    }
}
